
package com.zsrt.day20170505.homework.ch03;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

public class TongJiHang {

	public static void main(String[] args) throws IOException {
		File file = new File("src/com/zsrt/day20170505/homework/ch03/Node.java");
		
		Reader reader = new FileReader(file);
		
		BufferedReader bf = new BufferedReader(reader);
		String string ;
		//注释的行数
		int count =0;
		//代码的行数
		int i=0;
		//空格的行数
		int kg=0;
		boolean flag = false;
		while((string = bf.readLine()) !=null){
			string = string.trim();
			if(string.startsWith("//")){
				count ++;
			}else if(string.startsWith("/*")){
				//判断这种注释 : /*  */
				flag = true;
				count++;
				if(string.endsWith("*/")){
					flag = false;
				}
			}else if(string.equals("")){
				kg++;
				
			}else if(flag == true){
				//  判断 这种情况 /*
				    
				//         */
				count++;
				if(string.endsWith("*/")){
					flag = false;
				}
			}else if(string.startsWith("@")){
				count++;
				
			}else{
				i++;
			}
		}
		
		System.out.println("代码行："+i);
		
		System.out.println("注释行 "+count);
		System.out.println("空格行 "+kg);
	}
}
